void initNodes() 
{
  nodes   =  new Node[0];
  createNode("COORDINATOR", new XBeeAddress64("00 00 00 00 00 00 00 00") ); 
  createNode("NODE 1", new XBeeAddress64("00 13 a2 00 40 71 ce 4b") );
  createNode("NODE 2", new XBeeAddress64("00 13 a2 00 40 71 cd f8") );
  createNode("BROADCAST", new XBeeAddress64("00 00 00 00 00 00 FF FF") );
}

void createNode(String name, XBeeAddress64 addr) 
{
  nodes                 =  (Node[]) expand( nodes, nodes.length + 1 );
  nodes[nodes.length-1] =  new Node( name, addr );
}

class Node 
{
  int id;
  String name;
  XBeeAddress64 addr64;
  XBeeAddress16 addr16;
  
  Node( String n, XBeeAddress64 addr ) 
  { // initialisation sequence
    id     =  nodes.length-1;
    name   =  n;
    addr64 =  addr;
    addr16 = new XBeeAddress16(0xff,0xfe);
  }
  
  int[] getAddress64()
  {
    return addr64.getAddress();
  }
  
  int [] getAddress16()
  {
    return addr16.getAddress();
  }
  
  void setAddress16( int[] _addr16 )
  {
    addr16 = new XBeeAddress16(_addr16);
  }
}

XBeeAddress16 get16BitAddress(XBeeAddress64 _addr64) 
{
  XBeeAddress16 addr16 = new XBeeAddress16(0xff,0xfe);
  for (int i = 0; i < nodes.length; i++) {
    if (nodes[i].addr64.equals(_addr64)) {
      addr16 = nodes[i].addr16;
      break;
    }
  }
  return addr16;
}

XBeeAddress64 getReceiver( String s ) {
  XBeeAddress64 receiver = new XBeeAddress64( " 00 00 00 00 00 00 00 00 " ) ;
  for (int i = 0; i < nodes.length; i++) {
    if (s.equals(nodes[i].name)) { receiver = nodes[i].addr64; }
  }
  return receiver;
}

String getNodeName( XBeeAddress64 s ) {
  String nodeName = "";
  //XBeeAddress64 n = new XBeeAddress64( s ) ;
  for (int i = 0; i < nodes.length; i++) {
    if (s.equals(nodes[i].addr64)) { nodeName = nodes[i].name; }
  }
  return nodeName;
}

int getNodeIDFromName( String n ) {
  int nodeID = 0;
  //XBeeAddress64 n = new XBeeAddress64( s ) ;
  for (int i = 0; i < nodes.length; i++) {
    if (n.equals(nodes[i].name)) { nodeID = i; }
  }
  return nodeID;
}
